<!DOCTYPE html>
<html class="x-admin-sm">
<head>
<meta charset="UTF-8">
<title></title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="__ADMIN__/css/font.css">
<link rel="stylesheet" href="__ADMIN__/css/xadmin.css">
<script type="text/javascript" src="__ADMIN__/js/jquery.min.js"></script>
<script type="text/javascript" src="__ADMIN__/js/xadmin.js"></script>
<script type="text/javascript" src="__ADMIN__/js/cookie.js"></script>
{include file="public/layui" /}
<style>
	.layui-btn+.layui-btn{
    margin-left: 0;
}
</style>
</head>

<body>
<div class="x-nav">
	<span class="layui-breadcrumb">
		<a>
			<cite>销售部考核内容</cite>
		</a>
	</span>
	<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
		<i class="layui-icon layui-icon-refresh-3" style="line-height:30px"></i>
	</a>
</div>
<div class="x-body x-admin">
	<!--<xblock>-->

		<!--<a href="{:url('assessmentSalesman/assessmentList')}" class="layui-btn layui-btn-primary">全部</a>-->
		<!--{volist name="list" id="val"}-->
		<!--<a href="{:url('assessmentSalesman/assessmentList')}?job_id={$val.id}" class="layui-btn layui-btn-primary">{$val.name}</a>-->
		<!--{/volist}-->
	<!--	<br>-->
	<!--	<br>-->

	<!--</xblock>-->
	<div class="layui-table-body layui-table-main" style="width: 100%;">
		<table class="layui-table layui-form" id="assessment"></table>
	</div>
</div>
<script type="text/html" id="toolbarDemo">
		<button class="layui-btn" onclick="x_admin_show('新增考核项','{:url('assessmentSalesman/itemEdit')}',false,500,700)">
			新增考核项
		</button>
		<div class="layui-card-body" style="padding-left: 0;float:left;padding-left:0px;padding-top:0;">
			<form class="layui-form layui-col-space5" action="" method="get">
				<div class="layui-inline layui-show-xs-block">
					<input style="width:260px;" type="text" name="keywords" id="search" value="{:input('keywords')}" placeholder="请输入" autocomplete="off" class="layui-input">
				</div>
				<div class="layui-inline layui-show-xs-block">
                    <select name="job_id" lay-search>
                    <option value="">全部岗位</option>
                    {volist name="jobList" id="val"}
                    <option value="{$val.id}" {if $_GET['job_id'] == $val['id']} selected {/if} >{$val.name}({$val.count}人)</option>
                    {/volist}
                    </select>
				</div>
				<div class="layui-inline layui-show-xs-block">
					<button class="layui-btn" id="search-btn">
						<i class="layui-icon"></i>
					</button>
				</div>
			</form>
		</div>
</script> 

<script type="text/html" id="bar">
<div class="layui-clear-space">
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
</div>
</script> 

<script type="text/html" id="jobnameTpl">
{volist name="jobList" id="val"}
{{#  if(d.job_id == {$val.id}){ }}
{$val.name} ({$val.sum})
{{#  } }}
{/volist}
</script>
<script>
layui.use(['form','layer','jquery','table','util'], function(){
    form = layui.form,
    layer = layui.layer
    ,$ = layui.jquery
    ,table = layui.table
    ,util = layui.util;
    
    
    table.render({
        elem: '#assessment',
        url:'{:url('assessmentSalesman/itemList')}?limit=999&job_id={$_GET['job_id']}&keywords={$_GET['keywords']}', 
        toolbar: '#toolbarDemo',
        defaultToolbar: ['filter', 'exports', 'print', {
          title: '提示',
          layEvent: 'LAYTABLE_TIPS',
          icon: 'layui-icon-tips'
        }],
        height: $(window).height() - 200,
        cellMinWidth: 80,
        //totalRow: true, 
        limis: 9999,
        page: false,
        cols: [function(){
            var arr = [
                {field:'id', title:'ID', width:80, fixed: 'left'},
                {field:'job_id', toolbar:"#jobnameTpl", title:'所属岗位', width:150, fixed: 'left'},
                {field:'item_name', title:'考核项目', fixed: 'left', width:150},
                {field:'type_name', title:'维度',  width:60},
                {field:'max_score', title:'项目满分', width:90},
                {field:'index_desc', title:'指标要求', width:90},
                {field:'rule_desc', title:'评分规则'},
                {title:'操作', fixed: 'right', width:130, toolbar: '#bar'},
            ];
            
            // 初始化筛选状态
            var local = layui.data('table-filter-assessment'); 
            layui.each(arr, function(index, item){
                if(item.field in local){
                    item.hide = local[item.field];
                }
            });
            return arr;
        }() ],  
        done: function(){
            // 记录筛选状态
            var that = this;
            that.elem.next().on('mousedown', 'input[lay-filter="LAY_TABLE_TOOL_COLS"]+', function(){
                var input = $(this).prev()[0];
                // 此处表名可任意定义
                layui.data('table-filter-assessment', {
                    key: input.name
                    ,value: input.checked
                })
            });
        }
    });
    
    table.on('edit(assessment)', function(obj){
        var field = obj.field;
        var value = obj.value;
        var data = obj.data;
        layer.msg('编辑成功', {icon: 1});
        
        var update = {};return td.find('select').val();
        update[field] = value;
        obj.update(update);
    });
    
    table.on('tool(assessment)', function(obj){ // 双击 toolDouble
        var data = obj.data; // 获得当前行数据
        // console.log(obj)
        if(obj.event === 'edit'){
          layer.open({
            title: '编辑',
            type: 2,
            area: ['500px','700px'],
            content: '{:url('assessmentSalesman/itemEdit')}?id='+data.id
          });
        } else if(obj.event === 'del'){
            layer.confirm('确定删除此条吗?', function(index){
                $.post('{:url('assessmentSalesman/itemEdit')}',{status:-1,id: obj.data.id},function(){
                    window.history.go(0);
                })
            });
        }
    });
        
});

</script>
</body>

</html>